Latest Microsoft Dynamics 365 Blogs | CloudFronts

x++ code to import data from excel to D365 FnO

We can also import data through code in D365 FO. Data import through code in D365 works differently than Ax2012 since cloud services.  Import Class we are trying to import data from Excel to D365FO through the following code.   using System.IO; using OfficeOpenXml; using OfficeOpenXml.ExcelPackage; using OfficeOpenXml.ExcelRange;   class EmplAttendance { public void run() { this.updateDailyAttendance(); }   void updateDailyAttendance() { System.IO.Stream                     stream; ExcelSpreadsheetName            sheeet; FileUploadBuild                       fileUpload; DialogGroup                             dlgUploadGroup; FileUploadBuild                       fileUploadBuild; FormBuildControl                    formBuildControl; EmplAttendance_CFS              emplTimeAttendance, insertTimeAttendance, updateTimeAttendance; COMVariantType                     type; Dialog                      dialog =    new Dialog(“Daily Attendance Imported”);   dlgUploadGroup          = dialog.addGroup(“@SYS54759″); formBuildControl        = dialog.formBuildDesign().control(dlgUploadGroup.name()); fileUploadBuild           = formBuildControl.addControlEx(classstr(FileUpload), ‘Upload’); fileUploadBuild.style(FileUploadStyle::MinimalWithFilename); fileUploadBuild.fileTypesAccepted(‘.xlsx’);   str COMVariant2Str(COMVariant _cv) { switch (_cv.variantType()) { case COMVariantType::VT_BSTR: return _cv.bStr();   case COMVariantType::VT_EMPTY: return ”;   default: throw error(strfmt(“@SYS26908”, _cv.variantType())); } }   if (dialog.run() && dialog.closedOk()) { FileUpload fileUploadControl     = dialog.formRun().control(dialog.formRun().controlId(‘Upload’)); FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult();   if (fileUploadResult != null && fileUploadResult.getUploadStatus()) { stream = fileUploadResult.openResult();   using (ExcelPackage Package = new ExcelPackage(stream)) { int                         rowCount, i,columncount,j; Package.Load(stream); ExcelWorksheet   worksheet   = package.get_Workbook().get_Worksheets().get_Item(1); OfficeOpenXml.ExcelRange    range       = worksheet.Cells; rowCount           = (worksheet.Dimension.End.Row) – (worksheet.Dimension.Start.Row)  + 1; columncount      = (worksheet.Dimension.End.Column);     for (i = 2; i<= rowCount; i++) { str Emplid; TransDate                 WorkingDate; emplid                       = (range.get_Item(i, 1).value); WorkingDate            = str2Date((range.get_Item(i, 2).value),123);   select * from emplTimeAttendance where emplTimeAttendance.EmplId              = =  Emplid && emplTimeAttendance.WorkingDate       = =  WorkingDate;   if(emplTimeAttendance)     //if record already exists update it { emplTimeAttendance.selectForUpdate(true); emplTimeAttendance.Timein                          =   any2Str(range.get_Item(i, 3).value); emplTimeAttendance.Timeout                        =   any2Str(range.get_Item(i, 4).value); emplTimeAttendance.OT                                =  any2Real(range.get_Item(i, 5).value); ttsbegin; emplTimeAttendance.update(); ttscommit; } Else      //insert the new record { insertTimeAttendance.EmplId                         = (range.get_Item(i, 1).value); insertTimeAttendance.WorkingDate               = str2Date((range.get_Item(i, 2).value),123); insertTimeAttendance.Timein                         = any2Str(range.get_Item(i, 3).value); insertTimeAttendance.Timeout                       = any2Str(range.get_Item(i, 4).value); insertTimeAttendance.OT                                = any2Real(range.get_Item(i, 5).value); insertTimeAttendance.insert(); } } } } else { error(“Error here”); }   } }   public static void main (Args args) { EmplAttendance     emplDailyAttendanceImport;   emplDailyAttendanceImport = new EmplAttendance (); emplDailyAttendanceImport.run(); } }  

Share Story :

Steps to Configure Environments through Life Cycle Services (LCS)

Configuration of Environment through LCS. After we purchase licence, Login the LCS through Admin account. You can see the follow link to complete setup environment. Before configuring the environments there are some pre-requisites need to be performed. Declaration of project milestone. Click on setup milestone, Enter the end date for each milestone and save. 2. VSTS Setup. Before this we need to follow the below steps: Login in Azure DevOps. Create a project. 3. Create personal access token. Save this token. Click on “Setup Visual Studio Team Services” a.  Enter the site Enter the AzureDevOps url, which consists of https://organizationname.visualstudio.com/ and click on continue. Enter Personal access token generated above in Azure DevOps. b. Select the project Select the project from the list and click continue. c. Review and Save 3. Project configuration and project on-boarding. Click on “Complete project configuration”(This is one time setup) And click on “Project onboarding” Check all the 12 points by clicking on next and then finish the complete onboarding review page. And click on configure button of environment Enter the name of environment and select the region. Then you can see the status of environment in queued state. After 7-8 hours you can login to your environment.      

Share Story :

How to Add Workflow form for D365 finance and Operation modules

In D365 Finance and Operation for some modules, there is no Workflow setup. eg:- Inventory management module. In such a case, we need to perform the following steps after which you can see the workflow setup form which will include all the workflows for that specific module. First, we need to add the Display menu item and set properties as: Enum Type parameter to ModuleAxapta and Enum Parameter to the module ( in our case Inventory ) Object Type to form. Object to WorkflowtableListPageRnr   After this create a menu extension of the module where we need to place the form. Drag the display menu item to the menu extension.   After a successful build,  we are set to enlist new workflows for an inventory module using workflow forms. The same way you can attach workflow form to the new module as follows:- Create an extension of ModuleAxapta Base Enum Add a new element to base enum and name it your custom module name and label it Create a new Display Menu Item and set its properties as follows Create a new menu and set its label and name as per your requirement And insert your display menu item to your custom menu/module Create an extension of “MainMenu” Menu and add new menu item reference and set its properties as follows Build the solution your Workflow setup form will be visible for that module

Share Story :

Overview of Modern POS with Retail Store Scale Unit (RSSU)

Retail Store Scale Unit allows retailers to sell products within store locations that have internet connectivity issues, where it fails to connect with headquarters (HQ). Retail Store Scale Unit support both Modern POS and Cloud POS within the store. MPOS with Retail Store Scale Unit allows users to perform cross-terminal scenarios across multiple POS devices, like Suspend Shift Close Shift Blind Close Shift Manage Shift Inventory Lookup Stock Count Print X-Report Print Z-Report whereas Cloud-based MPOS offline fails to perform these operations. MPOS with Retail Store Scale Unit fails to perform real-time operations such as Issue/pay Gift Cards Issue Loyalty Card Picking and Receiving Pay by Customer Account Credit Card transactions Order Fulfillment View/Create Time clock entries unless there is internet connectivity to HQ or a payment provider. If most of your transactions involve real-time transactions, then your Store Scale Unit will always need internet connectivity to enable the connection to HQ or payment provider.

Share Story :

Move database from sandbox to development in D365 Finance and Operations

Hello, In this blog I am going to demonstrate how to move database from sandbox to development environment. In some cases, there might be a situation where you need to debug the code with production data. For this, first we need to move database from production to sandbox with refresh database  in LCS as shown in below screenshot. Then we need to move database from sandbox to development as follows. Steps to move database from Sandbox to Dev Login to LCS and click on Sandbox Environment full details. On Maintain Tab click Move database. To export the Sandbox Database, click on Export Database. 4.  You can find the .bacpac file in Database backup of asset library after successfully executing export command . Download the .bacpac file to development VM. 5. Open SSMS in development server. Before importing the database AxDB you must rename the existing AxDB by the following Script. USE master;  GO  ALTER DATABASE MyTestDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE MyTestDatabase MODIFY NAME = MyTestDatabaseCopy ; GO  ALTER DATABASE MyTestDatabaseCopy SET MULTI_USER GO 6. Right click on Database, select Import Data-tier Application. 7. Click Next. 8. Change the New database name to AxDB and click Next. 9. Click Next and Browse to the folder where .bacpac is downloaded. 10. Click Finish to import database. 11.  You can see the Steps as follows. 12. Once Import is done, Open Visual Studio and do Full Synchronization.   I hope this blog will help you.    

Share Story :

Model import and export in D365 Finance and Operations using Powershell

When we want to move customization done on specific model from one environment to other development environment we need to export and import the model file. Steps for model import and export using PowerShell :- Open PowerShell in administrator mode. Change directory to the path of package bin folder. Export command:-.\ModelUtil.exe -export -metadatastorepath=C:\AOSService\PackagesLocalDirectory -modelname=”name of model” -outputpath=path to store model after exportFor example: If model name is TOUpgradeModel and I want to store the model file to path is C:\Temp\ModelFile The command will be as follows: .\ModelUtil.exe -export -metadatastorepath=K:\AosService\PackagesLocalDirectory -modelname=”TOUpgradeModel” -outputpath=C:\Temp\ModelFile Output file you can see on the specified path as Import Command :-.\ModelUtil.exe -import -metadatastorepath=C:\AOSService\PackagesLocalDirectory -file=the path from. axmodel to importFor example: .\ModelUtil.exe -import -metadatastorepath=C:\AOSService\PackagesLocalDirectory -file=C:\Temp\ModelFile\TOUpgradeModel-Cloudfront.axmodel ( Note : If model already exist in your environment, trying to import the same model you will     receive the error message of “Model already exist”. So, delete the existing model by command .\ModelUtil.exe -delete -metadatastorepath=C:\AOSService\PackagesLocalDirectory -modelname=” TOUpgradeModel ” try to import the model)

Share Story :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange